Real World Windows 10 Development by Edward Moemeka & Elizabeth Moemeka
Author:Edward Moemeka & Elizabeth Moemeka
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA
In Listing 7-41, ToggleRecordVideo uses the familiar MediaCapture class to enable the video capture functionality. The only real difference between the code here and the code used in the audio capture samples is that the encoding profile is mapped to a video file format (in this case mp4). This choice is also reflected in the file extension used.
Background Audio
The previous section started delving into the intricacies of MediaElement. You saw how it can be used to play audio data located on the user’s machine or from a remote server. When these audio files play, however, they are designed by default to only play in the foreground. In the world of Windows 10, this means once you switch away from your app (minimize on the desktop), the sound stops. You can try this now with the app at this point. Start it and the Big Buck Bunny begins to play, minimize it (or navigate away from it on your Windows 10 mobile device/emulator) and the sound stops. Navigate back to the application, and the audio starts again. If you paid close attention to the playback time of the media when you navigated away, notice that it has increased in value from the point at which you navigated away (and also notice that the media is playing from a later position). This is because the audio has been playing while the app was shifted to the background. However, because audio configured in this manner can’t be heard when the app hosting it is no longer visible to the user, you hear nothing when you switch to a different app.
Enabling background playback requires three steps. First, you need to declaratively tell Windows that the MediaElement is designed for background audio playback. You then need to inform Windows of your intent to have the application running in the background (for the purpose of playing the audio). Finally, you need to hook your application up to the background audio playback infrastructure so that a user can use the Windows media playback controls to control the background audio. Let’s get started. Let’s implement background media playback for the video playing when the app starts (your “most recent event” video).
In the MediaElement tag, you assign a value to the AudioCategory property. The system uses this property to identify and manage the performance and integration of audio. When the value is set to BackgroundCapableMedia, it earmarks audio being played through the MediaElement as available to the background audio player.
The next step is to add a new declaration in the Declarations tab of the project’s package.appxmanifest configuration file. A background task must be implemented within a Windows Runtime Component, a kind of class library that can be interacted with from within any of the supported UWP languages. Right-click the Solution Explorer and add a new project to the solution entitled BMX.BackgroundTasks. Once created, remove the default class that is added (class1.cs) and add a new class called AudioPlayback. (Note that we will delve into background tasks in more detail in Chapter 9.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
NET | C & C++ Windows Programming |
SQL Server | VBA |
Visual Basic |
Deep Learning with Python by François Chollet(11923)
Hello! Python by Anthony Briggs(9388)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9354)
The Mikado Method by Ola Ellnestam Daniel Brolund(9321)
Dependency Injection in .NET by Mark Seemann(8867)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7861)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7353)
Grails in Action by Glen Smith Peter Ledbrook(7305)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7130)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5969)
Kotlin in Action by Dmitry Jemerov(4654)
Practical Vim (for Kathryn Amaral) by Drew Neil(3734)
Cracking the GRE Premium Edition with 6 Practice Tests, 2015 (Graduate School Test Preparation) by Princeton Review(3602)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3453)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3253)
Learning Java by Patrick Niemeyer & Daniel Leuck(2875)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(2852)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2847)
Microservices with Go by Alexander Shuiskov(2648)